<template>
  <div class="template_container">
    <div class="btn_box">
      <span class="page_num">共{{ 1 }}页</span>
      <!-- <el-button type="primary" plain> 上一页 </el-button> -->
      <!-- <el-button type="primary" plain> 下一页 </el-button> -->
      <el-button type="primary" @click.stop="toPrint">打印</el-button>
      <!-- <el-button type="primary" @click.stop="toPrint">全部打印</el-button> -->
      <el-button @click.stop="goBack">返回</el-button>
    </div>
    <div ref="print_area">
      <div
        class="assess_form swallow"
        v-for="(item, index) in infoList"
        :key="index"
      >
        <div class="form_title">XXXX医疗机构</div>
        <div class="form_name">高压氧质量中心多人空气加压氧舱医疗记录单</div>
        <table border>
          <tr>
            <td>姓名</td>
            <td>{{ currentPatient.patientName }}</td>
            <td>病案号</td>
            <td>
              {{
                currentPatient.patientType === 1
                  ? currentPatient.outpatientNum
                  : currentPatient.patientType === 2
                  ? currentPatient.admissionNum
                  : currentPatient.outpatientNum || currentPatient.admissionNum
              }}
            </td>
            <td>性别</td>
            <td>{{ currentPatient.genderName }}</td>
            <td>年龄</td>
            <td>{{ currentPatient.age }}</td>
            <td>住址</td>
            <td :colspan="6">{{ currentPatient.addr }}</td>
            <td>电话</td>
            <td :colspan="2">{{ currentPatient.phoneNum }}</td>
          </tr>
          <tr>
            <td>门诊</td>
            <td>
              <div class="data_cell">
                <el-checkbox :value="currentPatient.patientType === 1">
                  是
                </el-checkbox>
                <el-checkbox :value="currentPatient.patientType !== 1">
                  否
                </el-checkbox>
              </div>
            </td>
            <td>床号</td>
            <td>{{ currentPatient.bedNum }}</td>
            <td>主要诊断</td>
            <td :colspan="5">{{ currentPatient.coreDiagnosis }}</td>
            <td :colspan="3">操舱注意事项</td>
            <td :colspan="5">{{ item.preAdviceNote }}</td>
          </tr>
          <tr>
            <td>操舱医嘱</td>
            <td :colspan="9">
              <span>1、表压</span>
              <span class="under_line">{{ item.gaugePressure }}</span>
              <span>Mpa</span>
              <span class="s_title">2、方案 单次吸氧</span>
              <span class="under_line">{{ item.singleOxygenMinute }}</span>
              <span>分钟×</span>
              <span class="under_line">{{ item.singleOxygenNum }}</span>
              <span>次&nbsp;</span>
              <span>间隔吸空气</span>
              <span class="under_line">{{ item.intervalOxygenMinute }}</span>
              <span>分钟×</span>
              <span class="under_line">{{ item.intervalOxygenNum }}</span>
              <span>次</span>
              <span class="s_title">3、疗程</span>
              <span class="under_line">{{ currentPatient.exePeriod }}</span>
              <span>次/日×</span>
              <span class="under_line">{{ currentPatient.periodNum }}</span>
              <span>日</span>
            </td>
            <td :colspan="3">医生签名</td>
            <td :colspan="2">{{ item.doctorSign }}</td>
            <td>时间</td>
            <td :colspan="2">
              {{
                currentPatient.reservationTime
                  ? moment(currentPatient.reservationTime).format(
                      "YYYY-MM-DD HH:mm:ss"
                    )
                  : ""
              }}
            </td>
          </tr>
          <tr>
            <td :rowspan="3">次数日期</td>
            <td :colspan="5">入舱前评估</td>
            <td :colspan="6">操舱参数</td>
            <td :colspan="3">出舱后评估</td>
            <td :rowspan="3">下次操舱注意事项</td>
            <td :rowspan="3">入舱前后安检、宣教是否执行</td>
            <td :rowspan="2">操舱签名</td>
          </tr>
          <tr>
            <td :rowspan="2">不适主诉</td>
            <td :colspan="2">生命体征</td>
            <td :rowspan="2">跌倒</td>
            <td :rowspan="2">心理评估</td>
            <td :rowspan="2">加压起止时间（分钟）</td>
            <td :colspan="4">稳压阶段</td>
            <td :rowspan="2">减压起止时间（分钟）</td>
            <td>生命体征</td>
            <td :rowspan="2">跌倒</td>
            <td :rowspan="2">不适主诉</td>
          </tr>
          <tr>
            <td>{{ `T（℃）R（次/分）P（次/分）BP（mmHg）` }}</td>
            <td>疼痛</td>
            <td>单次吸氧、吸空气 时间×次数</td>
            <td>表压（Mpa）</td>
            <td>氧浓度（%）</td>
            <td>舱温（℃）</td>
            <td>{{ `T（℃）R（次/分）P（次/分）BP（mmHg）` }}</td>
            <td>家属确认</td>
          </tr>
          <tr>
            <td>
              <div>
                {{ item.resultInfo && item.resultInfo.treatmentNum }}
              </div>
              <div>
                {{
                  item.resultInfo &&
                  item.resultInfo.treatmentTime &&
                  moment(item.resultInfo.treatmentTime).format("MM-DD")
                }}
              </div>
            </td>
            <td>{{ item.resultInfo && item.resultInfo.discomfort }}</td>
            <td>
              <div class="grid_cell">
                <span>
                  T:{{ item.resultInfo && item.resultInfo.preTemperature }}
                </span>
                <span>
                  P:{{ item.resultInfo && item.resultInfo.prePulse }}
                </span>
                <span>
                  R:{{ item.resultInfo && item.resultInfo.preBreathing }}
                </span>
                <span>
                  BP:{{ item.resultInfo && item.resultInfo.preBloodPressure }}
                </span>
              </div>
            </td>
            <td>
              {{ item.resultInfo && item.resultInfo.pain }}
            </td>
            <td>
              <div class="data_cell">
                <el-checkbox
                  :value="
                    item.resultInfo ? item.resultInfo.fallRisk === 1 : false
                  "
                >
                  高危
                </el-checkbox>
                <br />
                <el-checkbox
                  :value="
                    item.resultInfo ? item.resultInfo.fallRisk === 2 : false
                  "
                >
                  非高危
                </el-checkbox>
              </div>
            </td>
            <td>
              <div class="data_cell">
                <el-checkbox
                  :value="
                    item.resultInfo ? item.resultInfo.psychology === 1 : false
                  "
                >
                  平静
                </el-checkbox>
                <br />
                <el-checkbox
                  :value="
                    item.resultInfo ? item.resultInfo.psychology === 2 : false
                  "
                >
                  其他
                </el-checkbox>
              </div>
            </td>
            <td>
              <div class="data_cell">
                <div>
                  起：
                  {{
                    item.resultInfo &&
                    item.resultInfo.compressionTimeBegin &&
                    moment(item.resultInfo.compressionTimeBegin).format("HH:mm")
                  }}
                </div>
                <div>
                  止：
                  {{
                    item.resultInfo &&
                    item.resultInfo.compressionTimeEnd &&
                    moment(item.resultInfo.compressionTimeEnd).format("HH:mm")
                  }}
                </div>
              </div>
            </td>
            <td>
              <div class="data_cell">
                <div>
                  吸氧
                  <span class="under_line">
                    {{ item.resultInfo && item.resultInfo.singleOxygenMinute }}
                  </span>
                  分钟×
                  <span class="under_line">
                    {{ item.resultInfo && item.resultInfo.singleOxygenNum }}
                  </span>
                  次
                </div>
                <div>
                  吸空气
                  <span class="under_line">
                    {{
                      item.resultInfo && item.resultInfo.intervalOxygenMinute
                    }}
                  </span>
                  分钟×
                  <span class="under_line">
                    {{ item.resultInfo && item.resultInfo.intervalOxygenNum }}
                  </span>
                  次
                </div>
              </div>
            </td>
            <td>{{ item.resultInfo && item.resultInfo.gaugePressure }}</td>
            <td>
              {{ item.resultInfo && item.resultInfo.oxygenConcentration }}
            </td>
            <td>{{ item.resultInfo && item.resultInfo.cabinTemperature }}</td>
            <td>
              <div class="data_cell">
                <div>
                  起：
                  {{
                    item.resultInfo &&
                    item.resultInfo.decompressionTimeBegin &&
                    moment(item.resultInfo.decompressionTimeBegin).format(
                      "HH:mm"
                    )
                  }}
                </div>
                <div>
                  止：
                  {{
                    item.resultInfo &&
                    item.resultInfo.decompressionTimeEnd &&
                    moment(item.resultInfo.decompressionTimeEnd).format("HH:mm")
                  }}
                </div>
              </div>
            </td>
            <td>
              <div class="grid_cell">
                <span>
                  T:{{ item.resultInfo && item.resultInfo.afTemperature }}
                </span>
                <span>
                  P:{{ item.resultInfo && item.resultInfo.afPulse }}
                </span>
                <span>
                  R:{{ item.resultInfo && item.resultInfo.afBreathing }}
                </span>
                <span>
                  BP:{{ item.resultInfo && item.resultInfo.afBloodPressure }}
                </span>
              </div>
            </td>
            <td>{{ item.name }}</td>
            <td>{{ item.name }}</td>
            <td>{{ item.resultInfo && item.resultInfo.nextAdviceNote }}</td>
            <td>
              <div class="data_cell">
                <el-checkbox
                  :value="
                    item.resultInfo
                      ? item.resultInfo.propagandaStates === 1
                      : false
                  "
                >
                  是
                </el-checkbox>
                <br />
                <el-checkbox
                  :value="
                    item.resultInfo
                      ? item.resultInfo.propagandaStates === 0
                      : false
                  "
                >
                  否
                </el-checkbox>
              </div>
            </td>
            <td>
              <div>操：{{ item.resultInfo && item.resultInfo.exeSign }}</div>
              <div>
                <img
                  :src="
                    currentPatient.psychologicalAssessment &&
                    currentPatient.psychologicalAssessment.signName
                  "
                  alt=""
                />
              </div>
            </td>
          </tr>
          <tr>
            <td :colspan="2">总治疗次数</td>
            <td>{{ currentPatient.periodNum }}</td>
            <td>疗效</td>
            <td :colspan="5">
              <el-radio-group :value="item.curativeEffect" size="medium">
                <el-radio
                  v-for="option in CURATIVE_EFFECT_LIST_1"
                  :key="option.value"
                  :label="option.value"
                >
                  {{ option.label }}
                </el-radio>
              </el-radio-group>
            </td>
            <template v-if="item.curativeEffect === 5">
              <td :colspan="3">中断治疗原因</td>
              <td :colspan="6">
                <el-radio-group
                  :value="item.treatmentInterruptionReason"
                  size="medium"
                >
                  <el-radio
                    v-for="option in INTERRUPT_REASON_LIST"
                    :key="option.value"
                    :label="option.value"
                  >
                    {{ option.label }}
                  </el-radio>
                </el-radio-group>
              </td>
            </template>
            <template v-else>
              <td :colspan="3"></td>
              <td :colspan="6"></td>
            </template>
          </tr>
        </table>
      </div>
    </div>
  </div>
</template>

<script>
import {
  CURATIVE_EFFECT_LIST_1,
  INTERRUPT_REASON_LIST,
  GENDET_LIST,
  getLabel,
} from "./enums";
import moment from "moment";
import Cookies from "js-cookie";
export default {
  name: "highPressureOxygenHistory",
  computed: {
    currentPatient() {
      try {
        const info = JSON.parse(Cookies.get("currentPatient"));
        return info
          ? {
              ...info,
              genderName: getLabel(info.gender, GENDET_LIST),
            }
          : {};
      } catch (res) {
        return {};
      }
    },
    infoList() {
      const { adviceHyperbaricOxygen } = this.currentPatient;
      if (adviceHyperbaricOxygen) {
        return [adviceHyperbaricOxygen];
      } else {
        return [];
      }
    },
  },
  data() {
    return {
      CURATIVE_EFFECT_LIST_1,
      INTERRUPT_REASON_LIST,
      formType: "edit",
    };
  },
  mounted() {},
  methods: {
    moment,
    goBack() {
      this.$router.back();
    },
    toPrint() {
      this.$print(this.$refs.print_area);
    },
  },
};
</script>

<style lang="scss" scoped>
@import url("~@/views/assessSys/templates/style.scss");
@import url("~@/views/assessSys/components/style.scss");

.record_item {
  .sign {
    margin-top: 10px;
    text-align: right;
  }
}

.page_num {
  margin-right: 20px;
}

.assess_form {
  width: 100%;
  padding: 20px;
}

table {
  width: 100%;

  td {
    padding: 2px 10px;
    text-align: center;

    .s_title {
      margin-left: 5px;
    }

    .under_line {
      // text-decoration: underline;
      padding: 0 5px;
    }

    .data_cell {
      text-align: left;

      span {
        padding-right: 10px;
      }

      .el-checkbox {
        margin-right: 10px;
      }

      div {
        white-space: nowrap;
      }
    }

    .grid_cell {
      text-align: left;
      display: grid;
      grid-template-columns: 1fr 2fr;
    }
  }
}
</style>
